
const router = require('koa-router')();
const util = require("../common/utils")
// const { sequelize } = require('../common/dbs')

// const userModel = require("../models/my")
// const userinfo = userModel(sequelize);
const tels = ['⁰', '¹', '²', '³', '⁴', '⁵', '⁶', '⁷', '⁸', '⁹']
const strs = {
    a: 'ᵃ', b: 'ᵇ', c: 'ᶜ', d: 'ᵈ', e: 'ᵉ',
    f: 'ᶠ', g: 'ᵍ', h: 'ʰ', i: 'ⁱ', j: 'ʲ',
    k: 'ᵏ', l: 'ˡ', m: 'ᵐ', n: 'ⁿ', o: 'ᵒ',
    p: 'ᵖ', q: 'ᵅ', r: 'ʳ', s: 'ˢ', t: 'ᵗ',
    u: 'ᵘ', v: 'ᵛ', w: 'ʷ', x: 'ˣ', y: 'ʸ', Z: 'ᙆ'
}
const strsLs = {
    a: 'ᵃ', b: 'ᵇ', c: 'ᶜ', d: 'ᵈ', e: 'ᵉ',
    f: 'ᶠ', g: 'ᵍ', h: 'ʰ', i: 'ⁱ', j: 'ʲ',
    k: 'ᵏ', l: 'ˡ', m: 'ᵐ', n: 'ⁿ', o: 'ᵒ',
    p: 'ᵖ', q: '�', r: 'ʳ', s: 'ˢ', t: 'ᵗ',
    u: 'ᵘ', v: 'ᵛ', w: '�', x: 'ˣ', y: 'ʸ', Z: 'ᙆ'
}

const zmStrs = {
    A: '𝓐', B: '𝓑', C: '𝓒', D: '𝓓', E: '𝓔',
    F: '𝓕', G: '𝓖', H: '𝓗', I: '𝓘', J: '𝓙', K: '𝓚', L: '𝓛', M: '𝓜',
    N: '𝓝', O: '𝓞', P: '𝓟', Q: '𝓠', R: '𝓡', S: '𝓢', T: '𝓣', U: '𝓤', V: '𝓥',
    W: '𝓦', X: '𝓧', Y: '𝓨', Z: '𝓩',
    a: '𝓪', b: '𝓫', c: 'c', d: '𝓭', e: '𝓮',
    f: '𝓯', g: '𝓰', h: '𝓱', i: '𝓲', j: '𝓳', k: '𝓴', l: '𝓵', m: '𝓶',
    n: '𝓷', o: '𝓸', p: '𝓹', q: '𝓺', r: '𝓻', s: '𝓼', t: '𝓽', u: '𝓾', v: '𝓿',
    w: '𝔀', x: '𝔁', y: '𝔂', z: '𝔃',
}

const telStr = '℡'
// tel 上标
router.get('/tel', async (ctx) => {
    try {
        let reqQuery = ctx.request.query;
        let str_arr = reqQuery.str.split('')
        let str_tel = ''
        for (let i = 0; i < str_arr.length; i++) {
            if (parseInt(str_arr[i]).toString() != 'NaN') {
                str_tel += tels[str_arr[i]]
            } else {
                str_tel += str_arr[i]
            }
        }
        ctx.body = util.resultSuccess({ data: telStr + str_tel });
    } catch (err) {
        console.log(err)
        ctx.body = util.resultError({ data: null });
    }
})
// 字母上标
router.get('/zm', async (ctx) => {
    try {
        let reqQuery = ctx.request.query;
        let str_arr = reqQuery.str.split('')
        let str_s = ''
        for (let i = 0; i < str_arr.length; i++) {
            Object.keys(strs).map(key => {
                if (key == str_arr[i]) {
                    str_s += strs[str_arr[i]]
                }
            })
        }
        ctx.body = util.resultSuccess({ data: str_s });
    } catch (err) {
        console.log(err)
        ctx.body = util.resultError({ data: null });
    }
})
// 花体英文
router.get('/ht', async (ctx) => {
    try {
        let reqQuery = ctx.request.query;
        let str_arr = reqQuery.str.split('')
        let str_s = ''
        for (let i = 0; i < str_arr.length; i++) {
            Object.keys(zmStrs).map(key => {
                if (key == str_arr[i]) {
                    str_s += zmStrs[str_arr[i]]
                }
            })
        }
        ctx.body = util.resultSuccess({ data: str_s });
    } catch (err) {
        console.log(err)
        ctx.body = util.resultError({ data: null });
    }
})


router.get('/strsLs', async (ctx) => {
    try {
        let reqQuery = ctx.request.query;
        let str_arr = reqQuery.str.split('')
        let str_s = ''
        for (let i = 0; i < str_arr.length; i++) {
            Object.keys(strsLs).map(key => {
                if (key == str_arr[i]) {
                    str_s += strsLs[str_arr[i]]
                }
            })
        }
        ctx.body = util.resultSuccess({ data: str_s });
    } catch (err) {
        console.log(err)
        ctx.body = util.resultError({ data: null });
    }
})
module.exports = router.routes();